<?php

require_once APPPATH . 'core/BaseDAO.php';

use models\M_cobrador_zona;

class CobradorZonaDAO extends BaseDAO {

    function __construct() {
        parent::__construct();
    }
	
    public function getCobradoresYZonas(){
		
        try {

            $query = $this->em->createQuery('SELECT c FROM models\M_cobrador_zona c');

            $cobradoresYZonas = $query->getResult();

            return empty($cobradoresYZonas) ? FALSE : $cobradoresYZonas;
			
        } catch (Exception $e) {
            return FALSE;
        }
    }
    
    public function getCobradorEnZona($zona){
        
        try {

            $query = $this->em->createQuery('SELECT c FROM models\M_cobrador_zona c JOIN c.zona z
                                                WHERE z.id=' . $zona);

            $cobradorEnZona = $query->getResult();

            return empty($cobradorEnZona) ? FALSE : $cobradorEnZona[0];
			
        } catch (Exception $e) {
            return FALSE;
        }
        
    }
		
}